import axios from '@/libs/server'
import Qs from 'qs'
// import axios from '@/libs.request'
const HOST = '' // http://10.101.3.176:8080 'http://10.101.7.145:8080' ||
// 机台分类列表
export const categoryList = data => {
  // let formData = new FormData()
  // Object.keys(data).forEach(key => {
  //   formData.append(key, data[key])
  // })
  // console.log(data)
  // formData.append('merchantId', this.merchantId)
  let url = `/machine/config/category_list`
  return axios.request({
    url: url,
    method: 'get',
    params: data
  })
}

// 添加编辑机台及参数
export const machineSave = data =>
  axios.request({
    url: `${HOST}/machine/save`,
    method: 'post',
    data: Qs.stringify(data),
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  })
// 添加编辑机台及参数 机台产品列表
export const machineList = data =>
  axios.request({
    url: `${HOST}/machine/list`,
    method: 'get',
    params: data
  })
// 获取机台产品SN序列
export const snGet = data => {
  // let params = Qs.stringify(data)
  // let formData = new FormData()
  // Object.keys(data).forEach(key => {
  //   formData.append(key, data[key])
  // })
  // debugger
  // console.log(`${HOST}/machine/sn/seq/get?pnCode=${data.get('pnCode')}&merchantId=${data.get('merchantId')}`)
  // debugger
  return axios.request({
    url: `${HOST}/machine/sn/seq/get`,
    method: 'get',
    params: data
  })
}

// 生成sn码记录并下载
export const snSave = data =>
  axios.request({
    url: `${HOST}/machine/sn/seq/save`,
    method: 'post',
    data,
    responseType: 'blob'
  })
// 生成sn码记录并下载
export const supplierList = data =>
  axios.request({
    url: `${HOST}/supplier/list/nopage`,
    method: 'post',
    data
  })
// 产品管理列表查询
export const machineRecord = data =>
  axios.request({
    url: `${HOST}/machine/record`,
    method: 'post',
    data
  })
// 产品管理列表导出
export const machineExport = data =>
  axios.request({
    url: `${HOST}/machine/export`,
    method: 'post',
    data,
    responseType: 'blob'
  })
// 产品管理列表导入验证
export const machineVerify = data =>
  axios.request({
    url: `${HOST}/machine/import/verify`,
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
// 产品管理列表导入y
export const machineImport = data =>
  axios.request({
    url: `${HOST}/machine/import`,
    method: 'post',
    data
  })
// 产品管理机台信息查询
export const machineQuery = data =>
  axios.request({
    url: `${HOST}/machine/query`,
    method: 'get',
    params: data
  })
// 严民的接口 : 资产发货单列表
export const invoiceList = data => axios.request({
  url: `/machine/invoice/query`,
  method: 'post',
  data
})
// 资产发货单导入效验
export const verifyXls = data => axios.request({
  url: '/machine/invoice/import/verify',
  method: 'post',
  data,
  headers: {
    'Content-Type': 'multipart/form-data'
  }
})
// 资产发货单导入
export const xlsImport = data => axios.request({
  url: '/machine/invoice/import',
  method: 'post',
  data
})
// 新增发货单信息
export const invoiceCreate = data => axios.request({
  url: '/machine/invoice/create',
  method: 'post',
  data
})
// 获取发货单详情
export const invoiceGet = data => axios.request({
  url: '/machine/invoice/get',
  method: 'post',
  data
})
// 发货单导出
export const invoiceExport = data => axios.request({
  url: '/machine/invoice/export',
  method: 'post',
  data,
  responseType: 'blob'
})
// 中止
export const invoiceClose = data => axios.request({
  url: '/machine/invoice/close',
  method: 'post',
  data
})
// 收货明细列表
export const receiptQuery = data => axios.request({
  url: '/machine/receipt/query',
  method: 'post',
  data
})
// 收货表明细导出
export const receiptExport = data => axios.request({
  url: '/machine/receipt/export',
  method: 'post',
  data,
  responseType: 'blob'
})
// 查询维修单列表
export const repairList = data => axios.request({
  url: '/machine/repair/list',
  method: 'post',
  data
})
//  机台相关字典查询
export const dictionaryQuery = data => axios.request({
  url: '/machine/dictionary/query',
  method: 'get',
  params: data
})
//  查询维修单详情
export const repairGet = data => axios.request({
  url: '/machine/repair/get',
  method: 'post',
  data
})
//  导出维修单记录
export const repairExport = data => axios.request({
  url: '/machine/repair/export',
  method: 'post',
  data,
  responseType: 'blob'
})
// 查询维修单详情
export const repairDetail = data => axios.request({
  url: '/machine/repair/get',
  method: 'get',
  params: data
})
// 强制结束维修单
export const forceFinish = data => axios.request({
  url: '/machine/repair/force/finish',
  method: 'post',
  params: data
})
// 机台统一监控列表接
export const machineMonitor = data => axios.request({
  url: '/machine/monitor/list',
  method: 'post',
  data
})
// 机台统一监控列表接 故障单详情
export const machineMonitorDetail = data => axios.request({
  url: `/machine/fault/get?machineFaultId`,
  method: 'get',
  params: data
})
// 机台统一监控列表接 建故障处理单
export const machineMonitorCheck = data => axios.request({
  url: '/machine/fault/check',
  method: 'post',
  data
})
// 机台统一监控列表接 查询故障单审核
export const machineMonitorReview = data => axios.request({
  url: '/machine/fault/review',
  method: 'post',
  data
})
//  机台统一监控列表接 机台实例信息查询 /machine/instance/query
export const machineInstanceQuery = data => axios.request({
  url: '/machine/instance/query',
  method: 'get',
  params: data
})
//  故障单列表查询
export const machineFaultList = data => axios.request({
  url: '/machine/fault/list',
  method: 'post',
  data
})
// 机台统一监控 导出
export const machineMonitorExport = data => axios.request({
  url: '/machine/monitor/export',
  method: 'post',
  data,
  responseType: 'blob'
})
